import {queryOrder} from "@src/api/catering";
import router from "@src/router";

Component({
  behaviors: [router.routerBehavior],
  data: {
    orderNo: null,
    item: null,
    orderInfo: null
  },
  methods: {
    onLoad(options) {
      let {orderNo} = options;
      this.setData({orderNo});
      this.fetchData();
    },
    fetchData() {
      queryOrder({orderNo: this.data.orderNo}).then(res => {
        if (res.code === 0) {
          let orderInfo = res.data;
          let item = null
          if (orderInfo.items && orderInfo.items.length > 0) {
            item = orderInfo.items[0]
          }
          this.setData({orderInfo, item})
        }
      })
    }
  }
})
